﻿@using Classified.Service
@model IEnumerable<Classified.Domain.Entities.ClassifiedAd>
@{
    ViewBag.Title = ViewBag.UserName+"'s Ads" ;
    Layout = "~/Views/Shared/_Layout.cshtml";
 
}
<div class="row" id="dvSearchList">
    <div class="span12">
        <h2>
            User's Ads :<small> @ViewBag.UserName</small>
        </h2>
         <table class="table">
        @foreach (var item in Model.Where(x=>x.IsEnhanced))
        {
            <tr>
                <td class="list-item-pic">
                    @if (item.ClassifiedPicture.Count == 0)
                    {
                        <img src="/Images/120/90/images/no-image.jpg" width="120" height="90" alt="@item.Title"
                             title="@item.Title" align="left"/>
                    }
                    else
                    {
                        <img src="/Images/120/90/classified/@item.ClassifiedPicture.FirstOrDefault().ImageGuid" width="120" height="90" alt="@item.Title"
                             title="@item.Title" align="left"/>
                    }
                    <span class="paid-customer">&nbsp;</span>
                </td>
                <td>
                     <h5>@item.Title</h5>
                @if (item.Price != 0)
                {<p>
                     Price : $@item.Price</p>}
                <p>
                    @if (item.Description.Length > 200)
                    {<text>@Html.Raw(@item.Description.Substring(0, 200) + "...")
                     </text>
                    }
                    else
                    {
                        <text>
                            @Html.Raw(item.Description)
                        </text>
                    }</p>
                <p>
                    <a class="btn" href="@Url.Action("Details", "ClassifiedAds", new { id = item.Id, seName = SeService.GetSeName(item.Title) })">
                        Read More »</a><span style="float: right"><i class="icon-comment"></i>comment(@item.ClassifiedComments.Count())</span></p>

                </td>
            </tr>
        }
        @foreach (var item in Model.Where(x=>x.IsEnhanced == false))
        {
            <tr>
                <td >
                    @if (item.ClassifiedPicture.Count == 0)
                    {
                        <img src="/Images/120/90/images/no-image.jpg" width="120" height="90" alt="@item.Title"
                             title="@item.Title" align="left"/>
                    }
                    else
                    {
                        <img src="/Images/120/90//classified/@item.ClassifiedPicture.FirstOrDefault().ImageGuid" width="120" height="90" alt="@item.Title"
                             title="@item.Title" align="left"/>
                    }
                    <span>&nbsp;</span>
                </td>
                <td>
                     <h5>@item.Title</h5>
                @if (item.Price != 0)
                {<p>
                     Price : $@item.Price</p>}
                <p>
                    @if (item.Description.Length > 200)
                    {<text>@Html.Raw(@item.Description.Substring(0, 200) + "...")
                     </text>
                    }
                    else
                    {
                        <text>
                            @Html.Raw(item.Description)
                        </text>
                    }</p>
                <p>
                    <a class="btn" href="@Url.Action("Details", "ClassifiedAds", new { id = item.Id, seName = SeService.GetSeName(item.Title) })">
                        Read More »</a><span style="float: right"><i class="icon-comment"></i>comment(@item.ClassifiedComments.Count())</span></p>

                </td>
            </tr>
        }
    </table>
       
        <div class="clear">
        </div>
    </div>
</div>
